﻿Imports System.Data.OleDb
Public Class AskAQuestion
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Btn_ask_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Btn_ask.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionStringList").ConnectionString)
        Dim sqlString As String = "INSERT INTO Question(Question,Author,DateUpdated) VALUES(@f1,@f2,@f3)"

        Dim cmd As New OleDbCommand(sqlString, oleDbConn)
        oleDbConn.Open()
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", Tb_Question.Text)
        cmd.Parameters.AddWithValue("@f2", User.Identity.Name)
        cmd.Parameters.AddWithValue("@f3", Convert.ToString(DateAndTime.Now))
        cmd.ExecuteNonQuery()
        oleDbConn.Close()
        Response.Redirect("AskAQuestion.aspx")
    End Sub
End Class